﻿using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using LTJ.Common;
using LTJ.Entity;
using LTJ.FrameWork;

namespace LTJ.Web.UI.datacontrol
{
    /// <summary>
    /// AJAX用户信息表
    /// </summary>
    public class ajaxuserlist : BaseWebControl
    {
        protected string search_txt_name = SASRequest.GetString("search_txt_name").Trim();
        protected string search_txt_ename = SASRequest.GetString("search_txt_ename").Trim();
        protected string search_txt_rname = SASRequest.GetString("search_txt_rname").Trim();
        protected int noinfid = SASRequest.GetInt("noinfid", 0);
        protected string epinfid = SASRequest.GetString("epinfid").Trim(',');
        protected int infid = SASRequest.GetInt("infid", 0);
        private string strWhere = "";
        private string orderstr = "";

        public override void ShowUserControl()
        {
            SetBaseDataVar();
            RowsCount = Users.GetUsersCount(strWhere);
            dataDT = Users.GetUsersByPage(PageIndex, PageSize, strWhere, orderstr);
            GetPageList("search_txt_ename=" + search_txt_ename + "&search_txt_name=" + search_txt_name + "&search_txt_rame=" + search_txt_rname + "&infid=" + infid + "&noinfid=" + noinfid + "&epinfid=" + epinfid);
        }

        /// <summary>
        /// 设置基本参数获取变量
        /// </summary>
        private void SetBaseDataVar()
        {
            if (controllername == "ajaxuserlist.ascx" || controllername == "ajaxuserlist_list.ascx")
            {
                showdiv = "ajaxuserdata";
                strWhere = Users.GetCorpManagerCondation(search_txt_name, search_txt_ename, search_txt_rname, true);
            }
            else if (controllername == "ajaxcorpuserlist.ascx" || controllername == "ajaxcorpuserlist_list.ascx")
            {
                showdiv = "ajaxcorpuserdatalist";

                if (noinfid > 0 || infid > 0) strWhere = Users.GetCorpUserCondationByCid(compid, search_txt_name, search_txt_ename, search_txt_rname, noinfid, infid);
                else strWhere = Users.GetCorpUserCondationByCid(compid, search_txt_name, search_txt_ename, search_txt_rname);
            }
            else if (controllername == "ajaxcorpmanagerlist.ascx" || controllername == "ajaxcorpmanagerlist_list.ascx")
            {
                showdiv = "ajaxcorpmanagerdatalist";
                strWhere = Users.GetCorpManagerCondation(compid, search_txt_name, search_txt_ename, search_txt_rname, true);
            }
            else if (controllername == "ajaxcorpusersellist.ascx" || controllername == "ajaxcorpusersellist_list.ascx")
            {
                showdiv = "ajaxcorpuserseldatalist";
                strWhere = Users.GetCorpUserCondationByFid(compid, infid, search_txt_name, search_txt_ename, search_txt_rname, epinfid);
            }
        }
    }
}
